package com.cse587.gae.dao;

import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;

import org.springframework.stereotype.Component;

import com.cse587.gae.dao.PopulationDao;
import com.cse587.gae.entities.Population;
import com.cse587.util.PMF;

@Component
public class PopulationDao {
	public List<Population> getPopulationList(String order){
		PersistenceManager pm = PMF.get().getPersistenceManager();
		Query query = pm.newQuery(Population.class);
		query.setOrdering("propertyValue "+order);
		query.setRange(0, 10);
		List<Population> populationList = (List<Population>) query.execute();
		//pm.close();
		return populationList;
	}
	
	public List<Population> getAll(){
		PersistenceManager pm = PMF.get().getPersistenceManager();
		Query query = pm.newQuery(Population.class);
		query.setOrdering("propertyValue asc");
		List<Population> populationList = (List<Population>) query.execute();
		//pm.close();
		return populationList;
	}
}
